<template>
  <div>
    <el-dialog
      title="编辑考卷"
      :visible.sync="dialogVisible"
      width="40%"
      :show-close="false"
      :close-on-click-modal="false">
      <el-form ref="dataForm" :model="dataForm" :rules="dataForm_rules" label-width="120px">
        <el-form-item label="考卷标题" prop="ep_name">
          <el-input v-model="dataForm.ep_name" size="small" style="width: 80%"></el-input>
        </el-form-item>
        <el-form-item label="考试时间(分钟)" prop="ep_test_time">
          <el-input-number v-model="dataForm.ep_test_time" :min="10" :max="200"></el-input-number>
        </el-form-item>
        <el-form-item label="考卷描述" prop="ep_describe">
          <el-input v-model="dataForm.ep_describe" size="small" style="width: 80%"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
      <el-button size="mini" @click="closeDialog">取 消</el-button>
      <el-button size="mini" type="primary" @click="updateInfo">确 定</el-button>
    </span>
    </el-dialog>
  </div>
</template>
<script>
  import {updateExaminationById} from '@/api/invigilate'
  export default{
      props:["isShowUpdateDialog","examinationPaper"],
      data(){
        return {

          dialogVisible:this.isShowUpdateDialog,
          dataForm:JSON.parse(JSON.stringify(this.examinationPaper)),

          dataForm_rules:{
            ep_name:[{ required: true, message: '不能为空', trigger: 'change' }],
            ep_test_time:[{ required: true, message: '不能为空', trigger: 'change' }],
            ep_describe:[{ required: true, message: '不能为空', trigger: 'change' }],
          }
        }
      },

      methods:{
        closeDialog(){
          this.dialogVisible = false;
          this.$emit("closeDialog","update");
        },

        updateInfo(){
           //提交数据
          updateExaminationById(this.dataForm).then(res=>{
              if(res.code == 200){
                this.$message({
                  message: '修改成功',
                  type: 'success'
                });
                this.closeDialog();
              }
          });
        }
      }
  }
</script>
